home *** CD-ROM | disk | FTP | other *** search
/ Aminet 20 / Aminet 20 (1997)(GTI - Schatztruhe)[!][Aug 1997].iso / Aminet / dev / misc / TdDBdevkit.lha / DataBase / support / TdDBaseLib.c < prev    next >
C/C++ Source or Header  |  1996-07-03  |  1KB  |  51 lines

  1.  
  2. /* TdDBase.Library Autoopen and Autoclose functions for SAS/C */
  3.  
  4. #include <proto/exec.h> 
  5. #include <constructor.h>
  6.  
  7. void __regargs __autoopenfail(char *);
  8.  
  9. struct Library *TdDBase;
  10. static void *libbase;
  11.  
  12. /* Define this in your program if you wish to open a specific version */
  13. extern long __tddbasever;
  14.  
  15. extern long __oslibversion;
  16.  
  17. CBMLIB_CONSTRUCTOR(opentddbase)
  18. {
  19.     TdDBase = libbase = 
  20.         (void *)OpenLibrary("tddbase.library", __tddbasever);
  21.  
  22.  
  23.     /* now, WHY doesnt OpenLibrary check these 2 places also? */
  24.     if(TdDBase == NULL)
  25.         TdDBase = libbase = 
  26.            (void *)OpenLibrary("PROGDIR:tddbase.library", __tddbasever);
  27.  
  28.     if(TdDBase == NULL)
  29.         TdDBase = libbase = 
  30.             (void *)OpenLibrary("PROGDIR:libs/tddbase.library", __tddbasever);
  31.  
  32.     if(TdDBase == NULL)
  33.     {
  34.         /* This is necesery if we want autoopenfail to report right version */
  35.         __oslibversion=__tddbasever;
  36.         __autoopenfail("tddbase.library");
  37.         return 1;
  38.     }
  39.  
  40.     return 0;
  41. }
  42.  
  43. CBMLIB_DESTRUCTOR(closetddbase)
  44. {
  45.    if(libbase)
  46.    {
  47.       CloseLibrary((struct Library *)libbase);
  48.       libbase = TdDBase = NULL;
  49.    }
  50. }
  51.